import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import get from '@dfeidao/atom-web/storage/get';

import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
import P01 from './P01';

export default async function a000(fd: IFeidaoAiBrowserComponent, args: { _id: string; group_id: string; role_allot_id: string; role_type_id: string; group: string; }, b_component_no: string) {

	//  调用事件
	fd.data.node.querySelector<HTMLDivElement>('[id="zj7"]').classList.remove('display-n');

	// console.log(args[0]);
	// console.log(args[1]);
	// debugger;
	if (args._id) {

		set(fd, 'x_id', args._id);
	}
	set(fd, 'group_id', args.group_id);
	set(fd, 'role_allot_id', args.role_allot_id);
	set(fd, 'role_type_id', args.role_type_id);
	set(fd, 'zj', b_component_no);
	const productid1 = get('productid');
	const role_type_id = args.role_type_id;
	fd.data.node.querySelector<HTMLFormElement>('#grouping').innerHTML = args.group;
	show_loading();
	const res = await nodejs<{ length: number }>('roler/zj-000007/s001', { productid: productid1, role_type_id }) as object[];
	hide_loading();
	// debugger;
	if (res.length === 0) {
		render(fd, '', P01, 'P01', 'inner');
	} else {
		const data = res.map((v) => {
			return { ...v, v: JSON.stringify(v) };
		});
		render(fd, data, P01, 'P01', 'inner');
	}
}
